﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<jsp:useBean id="dateValue" class="java.util.Date"/>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <!-- jsp文件头和头部 -->
    <%@ include file="../admin/top.jsp" %>

    <style>
        table tr td img {
            height: 25px;
            border-radius: 8%;
        }

    </style>
</head>
<body>
<div class="container-fluid" id="main-container">

    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <form action="device/listRemoteControl" method="post" name="userForm" id="userForm">
                    <input type="hidden" name="menuId" value="${page.menuId}">
                    <table style="width: 25%">
                        <tr>
                            <td>
						<span class="input-icon">
							<input style="margin-top: 0px;" autocomplete="off" type="text" name="searchValue"
                                   value="${page.searchValue}" placeholder="设备imei号"/>
						</span>
                            </td>
                            <td style="vertical-align:top;">
                                <button class="btn btn-mini btn-light" onclick="search();" title="检索">
                                    <i id="nav-search-icon" class="icon-search"></i>
                                </button>
                            </td>
                        </tr>
                    </table>
                    <table id="table_report" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>设备号</th>
                            <th>渠道名称</th>
                            <th>位置</th>
                            <th class="center">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:choose>
                            <c:when test="${not empty devices}">
                                <c:forEach items="${devices}" var="device">
                                    <tr style="text-align: center">
                                        <td>${device.id}</td>
                                        <td>${device.channel.name }</td>
                                        <td>
                                                ${device.loc.addr }
                                            <c:if test="${not empty device.loc.t}">
                                                <jsp:setProperty name="dateValue" property="time"
                                                                 value="${device.loc.t}000"/>
                                                (<fmt:formatDate value="${dateValue}" pattern="yyyy-MM-dd HH:mm:ss"/>)
                                            </c:if>
                                        </td>
                                        <td style="width: 60px;">
                                            <div class='hidden-phone visible-desktop btn-group'>
                                                <c:if test="${fn:contains(butSet, 'location')}">
                                                    <a class='btn btn-mini btn-info' onclick="locat('${account.id }');">
                                                        定位
                                                    </a>
                                                </c:if>
                                                <c:if test="${fn:contains(butSet, 'remote_shutdown')}">
                                                    <a class='btn btn-mini btn-info'
                                                       onclick="remoteShutdown('${account.id }');">
                                                        远程关机
                                                    </a>
                                                </c:if>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr class="main_info">
                                    <td colspan="10" class="center">没有相关数据</td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                    <div class="page-header position-relative">
                        <table style="width:100%;">
                            <tr>
                                <td style="vertical-align:top;">
                                    <div class="pagination"
                                         style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
    <i class="icon-double-angle-up icon-only"></i>
</a>
<!-- 引入 -->
<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/ace-elements.min.js"></script>
<script src="static/js/ace.min.js"></script>

<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
<script type="text/javascript">
    $(function () {
        top.hangge()
    });

    //检索
    function search() {
        top.jzts();
        $("#userForm").submit();
    }

    //定位
    function locat(id) {
        bootbox.confirm("是否对[" + id + "]发起定位?", function (result) {
            if (result) {
                top.jzts();
                var postParam = {"id": id};
                var url = "<%=basePath%>device/sendLocation";
                $.post(url, postParam, function (data) {
                    if (data.code == 200) {
                        nextPage(${page.currentPage});
                    } else {
                        alert(data.msg)
                    }
                });
            }
        });
    }

    //远程关机
    function remoteShutdown(id) {
        bootbox.confirm("是否对[" + id + "]远程关机?", function (result) {
            if (result) {
                top.jzts();
                var postParam = {"id": id};
                var url = "<%=basePath%>device/remoteShutdown";
                $.post(url, postParam, function (data) {
                    if (data.code == 200) {
                        nextPage(${page.currentPage});
                    } else {
                        alert(data.msg)
                    }
                });
            }
        });
    }

</script>
</body>
</html>
